package com.virtual.repository.common.model;

import java.io.Serializable;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Class representing the <strong>data-source</strong> element from configuration file.
 * It stores information about available database and parameters needed to connect to its.  
 * 
 * @author kchaber
 */
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "data-source")
public class DataSource implements Serializable {
	private static final long serialVersionUID = 5129239044631454910L;

	/**
	 * The unique identifier used to referencing to this object
	 */
	@XmlAttribute
	@XmlID
	private String id;
	
	/**
	 * The fully qualified class name, which implements the <code>IDatabasePlugin</>
	 */
	@XmlElement(name = "impl-class")
	private String implementationClass;
	
	/**
	 * The list of the parameters needed to connect to the database.
	 */
	@XmlElementWrapper(name = "parameters")
	@XmlElement(name = "parameter")
	private List<Parameter> parameters;
	
	public String getImplementationClass() {
		return implementationClass;
	}

	public void setImplementationClass(String implementationClass) {
		this.implementationClass = implementationClass;
	}

	public List<Parameter> getParameters() {
		return parameters;
	}

	public void setParameters(List<Parameter> parameters) {
		this.parameters = parameters;
	}

	@Override
	public String toString() {
		return getClass().getName() + " [id=" + id + ", implementationClass=" + implementationClass + ", parameters=" + parameters + "]";
	}
	
}
